package edu.zut.main.thread;

public class ThreadSleep {

    public static void main(String[] args) {
        new Thread(new CountDown()).start();
    }

}
//利用线程的休眠模拟倒计时
class CountDown implements Runnable{

    private int num = 10;

    @Override
    public void run() {
        while (true){
            if (num <= 0){
                break;
            }
            try {
                //利用sleep让其延时1s
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(num--);
        }
    }
}



